/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package specifications;

import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import org.yaml.snakeyaml.DumperOptions;
import org.yaml.snakeyaml.Yaml;
import org.yaml.snakeyaml.nodes.Tag;

/**
 *
 * @author Jason
 */
public class Style extends Parameter implements YamlObject<Style> {
    public static final Tag TAG = new Tag("!Style");
    private String styleGuide;
    private ArrayList<Directive> styleRelevance;
    
    public Style(){}
    public Style(String styleGuide, ArrayList<Directive> styleRelevance){
        setPriority(20);
        this.styleGuide = styleGuide;
        this.styleRelevance = styleRelevance;
    }
    @Override
    public ArrayList<Directive> getDirectives() {
        return this.styleRelevance;
    }

    @Override
    public void dump(String filename) throws IOException {
        Yaml yaml = new Yaml(CONSTRUCTOR, REPRESENTER);
        FileWriter writer = new FileWriter(filename);
        writer.write(yaml.dumpAs(this, TAG, DumperOptions.FlowStyle.BLOCK));
        writer.close();
    }

    @Override
    public Style load(String filename) throws IOException {
        Yaml yaml = new Yaml(CONSTRUCTOR, REPRESENTER);
        FileReader reader = new FileReader(filename);
        Style param = yaml.loadAs(reader, Style.class);
        reader.close();
        return param;
    }


    /**
     * @return the styleGuide
     */
    public String getStyleGuide() {
        return styleGuide;
    }

    /**
     * @param styleGuide the styleGuide to set
     */
    public void setStyleGuide(String styleGuide) {
        this.styleGuide = styleGuide;
    }

    /**
     * @return the styleRelevance
     */
    public ArrayList<Directive> getStyleRelevance() {
        return styleRelevance;
    }

    /**
     * @param styleRelevance the styleRelevance to set
     */
    public void setStyleRelevance(ArrayList<Directive> styleRelevance) {
        this.styleRelevance = styleRelevance;
    }
   
    
}
